package GreedyAlgorithm;
/*
 * 跳跃游戏 II
 */
public class lc45 {

    public int jump(int[] nums) {
        if (nums == null || nums.length == 0 || nums.length == 1) {
            return 0;
        }
        int res = 0;
        int cur = 0;
        int next = 0;
        for (int i = 0; i < nums.length - 1; i++) {
            next = Math.max(next, i + nums[i]);
            if (i == cur) {
                cur = next;
                res++;
            }
        }
        return res;
    }

}
